﻿using System;
using System.Collections;
using System.Configuration;
using System.Data; 
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.JCI.Common.Entity;
using Microsoft.JCI.Bll; 

namespace Microsoft.JCI.Portal.Dispatch
{
    public partial class WorkItemPartAdd : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["OrderID"] == null)
                {
                    btnOK.Enabled = false;
                }
            }
        }

        protected void btnOK_Click(object sender, EventArgs e)
        {
            DispatchBll bll = new DispatchBll();
            DisWorkingVenderPartsEntity entity = new DisWorkingVenderPartsEntity();

            entity.WorkingVenderPartsId = Guid.NewGuid();
            entity.WorkingVendorOrderId = new Guid(Request.QueryString["OrderID"]);
            entity.PartCode = txtPartCode.Text;
            entity.PartName = txtPartName.Text;
            if (txtCount.Value.HasValue)
                entity.Count = (int)txtCount.Value.Value;
            else
                entity.Count = 0;

            bll.InsertOrUpdate(entity);

            ClientScript.RegisterStartupScript(this.GetType(), "saveparts", "CloseWindow();", true);
        }

    }
}
